Skip to content

fix(codex): keep background memory out of chats - #5468

Open
AksharP5 wants to merge 6 commits into
pingdotgg:mainfrom
AksharP5:fix/codex-memory-consolidation
Open

fix(codex): keep background memory out of chats#5468
AksharP5 wants to merge 6 commits into
pingdotgg:mainfrom
AksharP5:fix/codex-memory-consolidation

Conversation

@AksharP5

@AksharP5 AksharP5 commented Aug 6, 2026

Copy link
Copy Markdown

What Changed

Codex memory consolidation runs in background threads, but T3 treated their notifications as part of the active chat. Internal messages and tool activity could therefore appear in the user's conversation.

T3 now recognizes both current and legacy memory-thread metadata and filters notifications from those threads before provider events are emitted. Tracking is removed when the internal thread closes.

Why

This keeps background memory maintenance isolated without hiding normal commentary, review or compaction work, or user-created subagents.

Fixes #4683

Validation

  • vp test run apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
  • vp lint apps/server/src/provider/Layers/CodexSessionRuntime.ts apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
  • vp run --filter t3 typecheck
  • vp fmt --check apps/server/src/provider/Layers/CodexSessionRuntime.ts apps/server/src/provider/Layers/CodexSessionRuntime.test.ts

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Screenshots are not applicable because no UI code changed
  • Video is not applicable because no animation or interaction changed

Built with gpt-5.6-sol using the Codex harness in T3 Code.

Note

Filter memory consolidation thread notifications out of Codex session events

  • Adds makeMemoryConsolidationNotificationFilter in CodexSessionRuntime.ts that tracks threads with threadSource === 'memory_consolidation' (or legacy { subAgent: 'memory_consolidation' } source) and returns a predicate to suppress their notifications.
  • Integrates the filter into makeCodexSessionRuntime so that CodexSessionRuntime.events never emits notifications for memory consolidation threads; suppression ends after thread/closed is received.
  • Behavioral Change: clients consuming CodexSessionRuntime.events will no longer see any events from memory consolidation sub-agent threads.

Macroscope summarized c512b45.


Note

Medium Risk
Changes Codex notification routing in the session runtime, which affects what every client sees on events; scope is narrow and well-tested but touches collab/stop paths alongside filtering.

Overview
Codex memory consolidation background threads were leaking into the user chat via CodexSessionRuntime provider events. This PR adds makeMemoryConsolidationNotificationFilter, which registers threads from threadSource: "memory_consolidation" or legacy source.subAgent: "memory_consolidation", suppresses all subsequent notifications for those thread IDs, and clears tracking on thread/closed.

handleRawNotification now drops suppressed notifications before collab/parent emission, so internal deltas and warnings never reach clients. Review, compaction, and user-spawned subagents are unchanged.

Tests cover filter behavior (including post-close forget) and extend the collab Stop integration scenario so memory consolidation threads still get turn/interrupt without surfacing as chat events.

Reviewed by Cursor Bugbot for commit c512b45. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0acce285-2c3b-4ad7-b89b-ec2b301ef56a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 6, 2026
@AksharP5
AksharP5 marked this pull request as ready for review August 6, 2026 03:48
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Aug 6, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces runtime behavior that filters memory_consolidation thread notifications from chat, preventing them from appearing in the UI. While well-tested, this is a meaningful change to notification visibility that warrants human review.

You can customize Macroscope's approvability policy. Learn more.

@AksharP5
AksharP5 force-pushed the fix/codex-memory-consolidation branch from 8f751f0 to dc5b475 Compare August 6, 2026 04:45

AksharP5 commented Aug 6, 2026

Copy link
Copy Markdown
Author

#5219 routes registered thread_spawn collaboration agents into the Agents surface. Memory consolidation is not registered through that path, and its item/agentMessage/delta notifications can still reach the parent chat.

This PR specifically recognizes memory_consolidation, tracks that thread, and suppresses its notifications without affecting normal subagents.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 78cec14. Configure here.

Comment thread apps/server/src/provider/Layers/CodexSessionRuntime.ts Outdated
@macroscopeapp
macroscopeapp Bot dismissed their stale review August 6, 2026 20:22

Dismissing prior approval to re-evaluate 48b0235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Background Codex memory activity appears in the active conversation

1 participant